package com.own.core.html.form.button;

import org.apache.wicket.ajax.AjaxRequestTarget;
import org.apache.wicket.ajax.markup.html.form.AjaxButton;
import org.apache.wicket.markup.html.form.Form;
import org.apache.wicket.markup.html.panel.FeedbackPanel;
import org.apache.wicket.model.Model;

import com.own.pages.Main;

public class OwnAjaxButton extends AjaxButton {

	FeedbackPanel feedbackpanel;

	public OwnAjaxButton(String id) {
		super(id);
		setOutputMarkupId(true);

	}

	public OwnAjaxButton(String id, FeedbackPanel feedbackpanel) {
		super(id);
		this.feedbackpanel = feedbackpanel;
	}

	public OwnAjaxButton(final String id, String label) {
		super(id, new Model<String>(label));

		setOutputMarkupId(true);
	}

	@Override
	protected void onSubmit(AjaxRequestTarget target, Form<?> form) {

	}

	@Override
	protected void onError(final AjaxRequestTarget target, final Form form) {
		if (feedbackpanel != null) {
			target.addComponent(feedbackpanel);;
		}
	}

}
